<div class="layui-collapse" lay-filter="test">
  {% for chapter in chapters %}
  <div class="layui-colla-item">
    {% if act_chapter and act_chapter.id == chapter.id %}
    <h2 class="layui-colla-title active-chapter">
    {%else%}
    <h2 class="layui-colla-title">
    {%endif%}
      <!-- {{chapter.chapter_name}} -->
      <a href="{% url 'study:studying' pk=course.id %}?chapter_id={{chapter.id}}">{{chapter.chapter_name}}</a>
    </h2>
    {% if chapter.children|length > 0 %}
      {% if act_chapter and act_chapter.parent_id == chapter.id%}
        <div class="layui-colla-content layui-show">
      {%else%}
        <div class="layui-colla-content">
      {%endif%}
        {% for cc in chapter.children %}
          {% if act_chapter and act_chapter.id == cc.id %}
            <h2 class="show-chapter-detail active-chapter" >
          {%else%}
            <h2 class="show-chapter-detail" >
          {%endif%}
              <a href="{% url 'study:studying' pk=course.id %}?chapter_id={{cc.id}}">{{cc.chapter_name}}</a>
            </h2>
          {% endfor %}
      </div>
    {%endif%}
  </div>
  {% endfor %}
</div>